

import { nextTick, onBeforeMount, onMounted, onUnmounted, ref } from "vue";
export default  function (e,el) {
 
  const x = ref(0)
  const y = ref(0)
  const show = ref(false)
  const handleMouseMove = (e,el) => {
    e.preventDefault();
    e.stopPropagation();
    x.value = e.clientX;
    y.value = e.clientY;
    show.value = true;
console.log( window.innerWidth,'x');

    
  };
  
  const closemenu = () => {

    
    show.value = false

  }
  

  onMounted(() => { 
    nextTick(() => {
      if (!e) return;
      const dom = e.value;
      dom.addEventListener("contextmenu", handleMouseMove);
       window.addEventListener("contextmenu", closemenu, true); //鼠标移动
      window.addEventListener("click", closemenu, true);
    });
  })

 
      

  onUnmounted(() => {
    console.log('我注销了');
    
     const dom = e.value;
          dom.removeEventListener("contextmenu", handleMouseMove);
          window.removeEventListener("contextmenu", handleMouseMove, true); //鼠标移动
          window.removeEventListener("click", closemenu, true);
 })


 
  return { show, x, y };
  
}